In [1]:
#!/usr/bin/env python
import os
import sys
if os.path.exists('/home/chieh/code/wuML'):
	sys.path.insert(0,'/home/chieh/code/wuML')
In [2]:
import wuml
import numpy as np

regression test
data is designed such that x₁, x₂ has minor positive impact x₄ has major negative,
5x₁ + x₂ + x₁x₂ - 8x₄ - 2x₄x₄ + δ

In [3]:
data = wuml.wData('../../data/shap_regress_example_gaussian.csv', first_row_is_label=True, 
					label_type='continuout', label_column_name='label', preprocess_data='center and scale')
In [4]:
model = wuml.regression(data, regressor='linear')
E = wuml.explainer(data, model, explainer_algorithm='shap')
exp = E(data)
  0%|          | 0/30 [00:00<?, ?it/s]

Most chosen
A 15
D 14
B 1
C 0

Most weighted
D 194.980919
A 170.815480
B 33.496118
C 10.028097

classification test

In [5]:
data = wuml.wData('../../data/shap_classifier_example.csv', first_row_is_label=True, 
					label_type='discrete', label_column_name='label')
In [6]:
model = wuml.classification(data, classifier='LogisticRegression')
E = wuml.explainer(data, model, explainer_algorithm='lime')
exp = E(data)

Most chosen
D 30
B 0
C 0
A 0

Most weighted
D 16.651401
B 2.784209
A 2.007877
C 0.870463